﻿import QtQuick 2.0
import QtQuick.Templates 2.12
import QtGraphicalEffects 1.14


CustomPopupBox{
    id: root
    height: 270*dp
    width: 400*dp
    property string box_text: "这是一个消息提示"
    property bool showAcceptedButton: true      // 确认按钮
    property bool showRejectedButton: true      // 取消按钮
    property var tempData       // 缓存数据
    property string acceptedText: "确定"
    property string rejectedText: "取消"
    property color overlayColor: "#14444444"
    title: ""

    signal accepted()
    signal rejected()

    contentItem: Item{
        id: content
        Image {
            y: 20*dp
            id: name
            anchors.horizontalCenter: parent.horizontalCenter
            height: 50*dp;  width: 50*dp
            source: "qrc:/picture/msgWarning.png"
        }

        Text{
            height: 100*dp
            lineHeight: 1.3
            font.pixelSize: config.fontsize
            anchors.horizontalCenter: parent.horizontalCenter
            y: 80*dp
            text: "提示"
        }

        Text {
            id: msgText
            lineHeight: 1.05
            font.pixelSize: config.fontsize
            anchors.centerIn: parent
            anchors.verticalCenterOffset: 15*dp
            wrapMode: Text.WordWrap
            horizontalAlignment: Text.AlignHCenter
            width: parent.width-70*dp
            color: "#999999"
            text: box_text
        }

        Row{
            height: 40*dp
            y: content.height - 70*dp
            anchors.horizontalCenter: parent.horizontalCenter
            spacing: 20*dp
            CustomButton{
                width: 100*dp
                title: rejectedText
                visible: showRejectedButton
                defaultMode2: true
                onReleased: {
                    root.rejected()
                    root.visible = false
                }
            }
            CustomButton{
                width: 100*dp
                visible: showAcceptedButton
                title: acceptedText
                defaultMode1: true
                onReleased: {
                    root.visible = false
                    root.accepted()
                }
            }
        }
    }
}
